'use strict'

const { Controller } = require('egg')
/**
 * @controller captcha 验证码接口
 */
class CaptchaController extends Controller {
	/**
	 * @summary 验证码
	 * @description 验证码
	 * @router get /admin/captcha
	 */
	async getCaptcha() {
		const ctx = this.ctx
		const captcha = await this.service.captcha.captcha()
		ctx.response.type = 'image/svg+xml'
		ctx.helper.success({
			data: captcha.data,
		})

		ctx.session.captchaCode = captcha.text.toLowerCase()
        console.log(ctx.session.captchaCode)
		ctx.session.maxAge = 1000 * 60 * 10
	}
}

module.exports = CaptchaController
